package org.random;

import java.util.Random;
import java.util.Scanner;

//猜数字游戏
public class RandomDemo1 {
    public static void main(String[] args) {
        Random random = new Random();
        int realNumber = random.nextInt(100)+1;

        Scanner sc = new Scanner(System.in);

        while (true){
            System.out.println("请输入您猜测的数据：");
            int guessNumber = sc.nextInt();
            if (guessNumber > realNumber){
                System.out.println("您猜的数字大了");
            } else if (guessNumber < realNumber) {
                System.out.println("您猜的数字小了");
            }else{
                System.out.println("您猜对了");
                break;
            }
        }

    }
}
